% test_DataPartition

%%

clear classes
clc

%% Load the Matlab built-in 'iris' dataset into @DataSet object

generate_dataset_iris;

%% @DataPartition::constructor

dp = DataPartition();
dp.setType('hold_out');

%% @DataPartition::shuffle

dp.shuffle(ds);

%% @DataPartition::Gets

id = dp.getZSeenId(1, 1);

% Get sub data mat in partition of 1st repetition, 1st fold, 1st sub-fold
[trnX, trnY] = dp.getTrnMat(ds, 1, 1, 1);
[valX, valY] = dp.getValMat(ds, 1, 1, 1);
[tstX, tstY] = dp.getTstMat(ds, 1, 1, 1);

% Get sub @DataMatrix object in partition of 1st repetiton, 1st fold, 1st
% sub-fold
[trnDmX, trnDmY] = dp.getTrnDataMatrix(ds, 1, 1, 1);
[valDmX, valDmY] = dp.getValDataMatrix(ds, 1, 1, 1);
[tstDmX, tstDmY] = dp.getTstDataMatrix(ds, 1, 1, 1);
assert((trnDmX.nRow + valDmX.nRow + tstDmX.nRow) == ds.nObs);

assert(isequal(trnX, trnDmX.mat) ...
    && isequal(valX, valDmX.mat) ...
    && isequal(tstX, tstDmX.mat));

%% @DataPartition::isIllOn

dp.isIllOn(ds); % >> [true?false]

%% @DataPartition::clone
dp2 = dp.clone();

%% @DataPartition::duplicate
dp3 = DataPartition();
dp3.duplicate(dp);
